home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
REFERENC
/
SWAG9505
/
SWAGADD.DOC
< prev
next >
Wrap
Text File
|
1995-05-27
|
10KB
|
227 lines
SWAGADD.EXE v1.0
(SWAG snipet ADDER)
(c) GDSOFT
May 1995
INTRODUCTION
------------
Since the inception of SWAG over two years ago, it has become a standard
library used by PASCAL programmers all over the world. I often receive mail
from users wanting to create their own SWAG packets. Therefore, I'm
releasing SWAGADD which is the program that I use to create the new snipets
every 90 days.
SWAG (.SWG) files are actually highly compressed LZH archive files with
extensions to the header and a double splayed sliding dictionary compressed
buffer.
The SWAG file headers have this structure :
TYPE
SwagHeader =
RECORD
HeadSize : BYTE; {size of header}
HeadChk : BYTE; {checksum for header}
HeadID : ARRAY [1..5] OF CHAR; {compression type tag}
NewSize : LONGINT; {compressed size}
OrigSize : LONGINT; {original size}
Time : WORD; {packed time}
Date : WORD; {packed date}
Attr : WORD; {file attributes and flags}
BufCRC : LONGINT; {32-CRC of the Buffer }
Swag : STRING[12]; {stored SWAG filename}
Subject : STRING[40]; {snipet subject}
Contrib : STRING[35]; {contributor}
Keys : STRING[70]; {search keys, comma deliminated}
FName : PathStr; {filename (variable length)}
CRC : WORD; {16-bit CRC (immediately follows FName)}
END;
Following each header is a highly compressed buffer optimized for space and
extraction speed. This makes the extraction or viewing of snipets VERY VERY
FAST. Unfortunately, you WILL NOT be able to use standard LZH code to
decompress this buffer, however, you'll find code in the SWAG distribution
to read the headers. Maybe someday, I'll release the decompression code to
the public domain, but for now, it's copyrighted, and unavailable.
GETTING STARTED
----------------
The program SWAGADD.EXE is a executable program that will allow you to read
a directory of files and add them selectively to .SWG files somewhere on
your disk. Any files can be added to any .SWG file. The only limitations
are that the file must be an ASCII file and less than 64K is size.
Actually, you could save ANY thing in a SWAG file. Recipes, Assembler code,
"C" code or any type of ASCII files. I have a friend who keeps his favorite
recipes in .SWG format. You wil find that you'll get compression ratios
almost as good as PKWARES PKZIP. The main feature is that once data is
added, you'll find that the extraction ratio is MUCH faster than PKZIP.
USING SWAGADD
-------------
Using the program is really very simple. Just execute it, and you will be
presented with a directory of all of the .files in the directory that you
started from. You'll be able to navigate by simply selecting one of the
directory entries instead of one of the actual files. You'll notice that
some files in the directory will NOT be listed; EXE, COM, ZIP, ARJ, LZH
etc. Use the HOME, END and the arrow keys to maneuver around.
ALSO,
The directory window is search key sensitive. This means that directory
box, you can just type the name of the file you want. For example, pressing
'A' will place you at the first entry starting with 'A'. Press 'N', and you
will jump the the entry with 'AN...' if you have one. If NOT, you will jump
the first file starting with the letter 'N'.
At the bottom of the screen you will notice a menu indicating some cursor
and function keys :
F1 - HELP
F3 - OPTIONS
AltM - Mask
<ENTER> - Read
ESC - QUIT
F1 shows you a little help screen for both the file selection window and
the snipet window.
F3 let's you set some options that are available.
AltM permits you to enter a specific path and mask.
<ENTER> opens up the snipet window, and all for some additional command
keys:
ALT[N],
CTRL[ENTER] - View the NEXT snipet
ALT[V] - View PREVIOUS snipet
ALT[S] - Save Snipet
This is the main function of SWAGADD. You'll be able to enter the subject,
from, and keys that you want included in the packet. You'll be prompted for
the .SWG file where you want to put the snipet, and also you will be given
the opportunity to enter the packet description. If the .SWG files does not
already exist, it will be created.
AUTOMATIC HEADERS
-----------------
You can include the following on the FIRST line of you snipet file,
{SWAG=SWAGFNAME,FROM,SUBJECT,KEYS}
SWAGADD will parse this string if found, and default the SWAG
filename, from, subject and keys for you automatically. This makes
adding a directory of files very easy and fast.
ALT[F] - SWAG File
------------------
Allows you enter the SWAG files that the snipet will be included in.
ALT[C] - Check for Duplicate
----------------------------
This activates a function that attempts to insure that this snipet is an
original. EVERY snipet in every .SWG files is checked against the snipet to
be added for duplication. The technique is not fool-proof, and used two
methods to do the analysis. First, every PROCEDURE and FUNCTION is checked
to a percentage of matches. Greater than 50% indicates a possible match.
Next, the entire text is checked line by line. If we get 66% or better
matches, then we can assume that we probably have a duplicate snipet. At
least it is very very close.
As the process runs, you'll notice at the bottom of the screen :
SOMEFILE.PAS in ANSI.SWG 0009 01/01 11/68 16%
^ ^ ^ ^ ^ ^
File Name SWAG File No. Procs Text Pct
This shows the possible "finds" as it checks each snipet. If the screen
turns dark blue, then you probably have a duplicate, and a box will pop on
the screen and allow to mark the file, view the snipet involved or skip and
proceed. You'll have to make the decision as to whether you want to add it
or not.
ALT[G] - GREP
-------------
The GREP function is another tool designed to help you decide if you have a
duplicate snipet or not.
Enter a string to search for. You may search for a multiple occurrence of
substrings using BOOLEAN operators AND (&) OR (|). For example, a search
for THIS&THAT|THEM&THOSE would return all snipets containing both ORed
phrases THIS&THAT OR THEM&THOSE.
In BOOLEAN Algebra, the AND operator takes precedence over the OR operator
(except when using parentheses). This is NOT the case with the GREP
function. You can use the PARENTHESES () to dictate which portion of the
search string is to be processed first. If multiple levels of parentheses
are used, the order is RIGHT to LEFT, starting with the innermost set of
parentheses, wherever they occur.
As an example, in the phrase ((this|that)&(them&those)), (them&those) would
be processed before (this|that)) innermost to outermost. In other words,
all snipets will be returned containing THIS or THAT AND they also will
contain (THEM and THOSE).
Within a set of parentheses, order will be left to right. Construction of
the search string itself requires combining the desired substrings together
with the desired BOOLEAN operators. Without the parentheses, the search
string will be processed logically. THIS|THAT&THEM&THOSE will return all of
the snipets that contain THIS plus the ones that contain THAT & THEM &
THOSE. You can see that this is totally different than what you'll get by
using the parentheses.
The program will search ALL of the SWAG packet HEADERS in the CURRENT
directory for matches based on your criteria. A processing box will appear,
and all occurrences of your search string(s) or date matches will be
written to a NEW SWAG file. Initially, this file is named GREPSWAG.SWG, and
will be in the current directory. Upon completion of this GREP process, you
will be asked for the file name. Enter any name AND directory you choose,
and the file will be RENAMED and moved to that directory. Pressing ESCAPE
WILL NOT save a file at all. This process allows you to create SWAG files
containing ANY combination of material that you please.
You can ALSO search the ENTIRE SWAG snipet buffer for data. Just enter a
tilde (~) character as the FIRST character on the search line. For instance
to find all snipets containing CRT, you would enter ~CRT on the search
line. ONLY the header of snipets is searched for matches. This a way you
can look at all snipets by a certain contributor. You can also use multiple
search criteria here. For instance, ~GAYLE DAVIS|GUY MCLOUGHLIN|JOE BLOW
would bring back everything for each of these persons. This search method
is VERY fast as on the headers have to be read. By the way, the same rules
about AND/OR searching apply when search just the headers.
THE SWAG ENVIRONMENT VARIABLE
-----------------------------
Some users reported a considerable delay while SWAG programs looked for the
.SWG files on their disks. This problem has been eliminated by adding the
environment variable SWAG to allow total override of the SWAGDIR= switch in
the READER.INI. Use the command :
SET SWAG=yourpath
at the DOS prompt to set this. This then become the ABSOLUTE location that
READER and other programs use to as the beginning path for SWAG files and
WILL OVERRIDE you setting in the READER.INI file.
We hope that you find this program easy to use, and the SWAG material
valuable in development of your PASCAL programs.
ENJOY !!!!! and GOOD PROGRAMMING !!!
Gayle Davis